@extends('admin.common.main')

@section('content')
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户中心 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div class="text-c"> 日期范围：
            <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
            -
            <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
            <input type="text" class="input-text" style="width:250px" placeholder="输入会员名称、电话、邮箱" id="" name="">
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="" onclick="datadel()" class="btn btn-danger radius deleteAll"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
                <a href="showAdd" onclick="member_add('添加用户','member-add.html','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a>
             <a href="restore" onclick="member_add('回收站','member-add.html','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 回收站</a> </span> <span class="r">共有数据：<strong>88</strong> 条</span>

       </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" id="checkAll" name="" value=""></th>
                    <th width="80">ID</th>
                    <th width="100">用户名</th>
                    <th width="40">真实姓名</th>
                    <th width="90">手机</th>
                    <th width="150">邮箱</th>
                    <th width="30">性别</th>
                    <th width="130">加入时间</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $key=>$val)
                    <tr class="text-c">
                        <td><input type="checkbox" class="check" data-id="{{$val['id']}}" value="1" name=""></td>
                        <td>{{$val['id']}}</td>
                        <td>{{$val['username']}}</td>
                        <td>{{$val['truename']}}</td>
                        <td>{{$val['phone']}}</td>
                        <td>{{$val['email']}}</td>
                        <td>{{$val['sex']}}</td>
                        <td>{{$val['created_at']}}</td>
                        <td class="td-manage">
                            <a title="编辑" href="javascript:;" class="label label-primary radius">编辑</a>
                            <a title="删除" href="/del/{{$val['id']}}" class="label label-danger radius delbtn">删除</a>

                    </tr>
                @endforeach
                </tbody>
            </table>

            {{$data->links()}}
        </div>
    </div>

@endsection

@section('js')
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(function () {
            $("#checkAll").click(function () {
                if (this.checked){
                    $(".check").prop('checked',true)
                }else {
                    $(".check").prop('checked',false)
                }
            })

            $('.deleteAll').click(function () {

                let arr = [];
                let count = 0;
                $("input[type=checkbox]:checked").each(function () {
                    arr.push($(this).attr('data-id'));
                    count++;
                })
                console.log(arr);
                if (count==0){
                    alert('不能删除');
                    return false;
                }
                $.ajax({
                    url:'/delAll',
                    data:{id:arr},
                    dataType:'json',
                    type:'post',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    success:function (res) {
                        if (res.code==200){
                            alert('成功')
                        }else{
                            alert('失败')
                        }
                    }
                })

            })

        })

    </script>
@endsection
